#include <iostream>
#include "Log.hpp"
#include "EpollServer.hpp"
#include "Listener.hpp"
#include "Connection.hpp"

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << "port" << std::endl;
        return 1;
    }
    ENABLE_CONSOLE_LOG();
    uint16_t local_port = std::stoi(argv[1]);
    EpollServer epoll_svr;
    auto conn = std::make_shared<Listener>(local_port);

    // auto conn = Facotry::BuildConnection(listen.SockFd(), EPOLLIN | EPOLLOUT, [&listen]()
    //                                      { listen.Accepter(); }, nullptr, nullptr);

    epoll_svr.InsertConnection(conn);
    epoll_svr.Loop();
    return 0;
}